<?php

	$cache = false;

	//Debut du traitement du cache 
	if ($cache){
		$dossier_cache = 'cache/'; 
		$secondes_cache = 60*60*12; // 12 heures 
		  
		$url_cache = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 
		$fichier_cache = $dossier_cache . md5($url_cache) . '.cache'; 
		  
		$fichier_cache_existe = ( @file_exists($fichier_cache) ) ? @filemtime($fichier_cache) : 0; 
		  
		if ($fichier_cache_existe > time() - $secondes_cache ) { 
		  @readfile($fichier_cache); 
		  exit(); 
		  } 
		ob_start(); 
	}

	//Constante globale 
	global $WIKIPEDIA, $WIKINEWS, $WIKTIONNARY, $PARAMS, $ACCUEIL, $ERREUR;
	
	$WIKIPEDIA = 0;
	$WIKTIONNARY = 1;
	$WIKINEWS = 2;
	$PARAMS = 3;
	$ACCUEIL = 4;
	$ERREUR = 5;
	
	session_start();
	
	//Model
	require('model/Element.class.php');
	require('model/Header.class.php');
	require('model/Image.class.php');
	require('model/Link.class.php');
	require('model/List.class.php');
	require('model/ElementList.class.php');
	require('model/Paragraph.class.php');
	require('model/Table.class.php');
	require('model/Text.class.php');
	require('model/Audio.class.php');
	
	//Model::Parser
	require('model/Parser.class.php');	
	
	require('model/Model.class.php');
	
	//Controller
	require('controller/controller.class.php');
	require('controller/wikinewsController.class.php');
	
	//VIEW
	require_once('view/view.class.php');
	
	$model = new Model();
	
	$controller = new Controller($model);
	
	global $view;
	$view = new View($controller->getPage());
	$view->render();
	
	
	//Fin traitement du cache
	if ($cache){
		$pointeur = @fopen($fichier_cache, 'w'); 
		@fwrite($pointeur, ob_get_contents()); 
		@fclose($pointeur); 
		ob_end_flush(); 
	}
?>